<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<style type="text/css">
    .msg {
        /*overflow: hidden;*/
        white-space: nowrap;
        text-overflow: ellipsis;
        width: 50px;
    }

    td {
        text-align: left;
        word-wrap: break-word;
        word-break: break-all;
    }

</style>
<div class="msglist">
    <table class="table table-hover">
        <tr>
            <td style="width:15%;"><b>发送信息详情名称</b></td>
            <td style="width:10%;"><b>年</b></td>
            <td style="width:5%;"><b>月</b></td>
            <td style="width:5%;"><b>周</b></td>
            <td style="width:10%;"><b>日</b></td>
            <td style="width:10%;"><b>时</b></td>
            <td style="width:10%;"><b>分</b></td>
            <td style="width:10%;"><b>秒</b></td>
            <td style="width:10%;"><b>创建时间</b></td>
            <td style="width:10%;"><b>操作</b></td>
        </tr>
        <c:forEach var="m" items="${list}">
            <tr>
                <td style="width:10%;word-wrap:break-word;">
                    <c:forEach var="set" items="${sets}">
                        <c:if test="${set.sendid==m.sendid}">
                            <div class="msg" title=${set.infoname}>${set.infoname}</div>
                        </c:if>
                    </c:forEach>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.year}>${m.year}</div>
                </td>
                <td style="width:5%;word-wrap:break-word;">
                    <div class="msg" title=${m.month}>${m.month}</div>
                </td>
                <td style="width:5%;word-wrap:break-word;">
                    <div class="msg" title=${m.week}>${m.week}</div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.day}>${m.day}</div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.hour}>${m.hour}</div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.minute}>${m.minute}</div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.second}>${m.second}</div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div class="msg" title=${m.createtime}><fmt:formatDate
                            type="date"
                            value="${m.createtime}"
                            dateStyle="default"
                    /></div>
                </td>
                <td style="width:10%;word-wrap:break-word;">
                    <div>
                        <button class="orderlist-cancelorder-btn" onclick="editMail(${m.jobid})">
                            修改
                        </button>
                        <button class="orderlist-cancelorder-btn" onclick="deleteMail(${m.jobid})">
                            删除
                        </button>
                    </div>
                </td>
            </tr>
        </c:forEach>
    </table>
    <c:if test="${empty list}">
        <div class="nodata-tip"> 暂未发现符合条件的数据。</div>
    </c:if>
</div>

<!-- Modal 通用提示消息模态框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    //删除邮件设置
    function deleteMail(id) {
        $.ajax({
            type: "GET",
            url: "${contextPath}/jobset/deleteJob?id=" + id,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    location.reload();
                } else {
                    mailsetmsg(data.message);
                }
            },
            error: function (err) {
                mailsetmsg("服务器错误，请稍后重试");
            }
        })
    }
    function mailsetmsg(msg) {
        $('#myModal').on('show.bs.modal', function () {
            var modal = $(this);
            modal.find('.modal-title').text('提示');
            modal.find('.modal-body').text(msg);
        });
        $('#myModal').modal({
            backdrop: 'static',
            keyboard: false
        });
    }
</script>